<template>
  <!-- 规则定义子页面 分摊动因 动因基本信息查看子页面-->
  <div>
    <el-form
      :model="saveForm"
      ref="saveOrEditRef"
      label-width="100px"
      label-position="left"
      :rules="saveFormRules"
    >
      <el-row>
        <el-col :span="10" :offset="1">
          <el-form-item label="动因编码：" prop="driverCode" required>
            <el-input
              v-model="saveForm.driverCode"
              maxlength="40"
              :disabled="operateType == 2 || operateType == 3"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="10" :offset="1">
          <el-form-item label="动因名称：" prop="driverName" required>
            <el-input
              v-model="saveForm.driverName"
              maxlength="40"
              :disabled="operateType == 3"
            ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="10" :offset="1">
          <el-form-item label="类型: " prop="driverType" required>
            <el-radio-group v-model="saveForm.driverType">
              <el-radio :label="'0'">静态动因表</el-radio>
              <el-radio :label="'1'">动态动因</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="10" :offset="1">
          <el-form-item label="权限: " prop="driverAuthority" required>
            <el-radio-group v-model="saveForm.driverAuthority">
              <el-radio :label="'0'">任何人可读写</el-radio>
              <el-radio :label="'1'">创建人可读写其他人可读</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="20" :offset="1">
          <el-form-item label="描述: " prop="driverDesc">
            <el-input
              type="textarea"
              :rows="3"
              v-model="saveForm.driverDesc"
              maxlength="40"
              :disabled="operateType == 3"
            ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>
<script>
import { ruleDefinition } from "@/api/index";
export default {
  name: "basicAgent",
  components: {},
  props: {
    driverCode: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      operateType: "3",
      saveForm: {
        driverCode: "",
        driverName: "",
        driverType: "",
        driverAuthority: "",
        driverDesc: "",
      },
      addRuleBasic: {
        ruleCode: "",
        ruleName: "",
        sceneCode: "",
        ruleType: "",
        descn: "",
      },
      //表单字段规则校验
      saveFormRules: {
        driverCode: [
          { required: true, message: "该输入项为必输项", trigger: "blur" },
        ],
        driverName: [
          { required: true, message: "该输入项为必输项", trigger: "blur" },
        ],
        driverType: [
          { required: true, message: "该输入项为必输项", trigger: "blur" },
        ],
      },
    };
  },
  mounted() {
  },
  methods: {
    init() {
      let params = {
        driverCode: this.driverCode,
        page: 1,
        size: 15,
      };
        ruleDefinition.ruleDriverQuery(params).then(res => {
        if (res.code === 200) {
          this.saveForm = res.datas.rows[0];
          this.total = res.datas.total;
        } else{
            this.$message.error(res.message)
        }
      });

    },
  },
};
</script>
<style lang="scss" scoped></style>